// This is the key counting observer for ObserverPatternV2 12/8/2011

#include <iostream>
#include "CountKeys.h"


using namespace std;


CountKeys::CountKeys(void)
{
	count = 0;
	msg = "Key Counter";
	//  wordsFoundCount = 0;
}

CountKeys::CountKeys(string theMessage)
{
	count = 0;
	msg = theMessage;
	//  wordsFoundCount = 0;

}

CountKeys::~CountKeys(void)
{
}

bool CountKeys::subscribe(event e)
{
	return (Notifier::getInstance())->subscribe(this,e);
}

bool CountKeys::unsubscribe(event e)
{
	return (Notifier::getInstance())->unsubscribe(this, e);
}

void CountKeys::notify(event e, string data)
{
	switch (e)
	{
	case KEY_EVENT:
		count++;
		cout << "    [" << msg << "] The count is now "<< count << endl;
		break;
	case CLASS_EVENT:
		if (data == "PRINT")
		{
			cout << "    [" << msg << "] Total key count is: " << count << endl;
		}
		break;
	default:
		cout << "    [" << msg << "] Event not recognized." << endl;
	}
}
